const Router = require("koa-router");
const momentRouter =new Router({
    prefix: "/moment" // 前缀
});
const {createMoment,detail,list,deleteMoment,updateMoment,createLabel,getFileInfo} = require("../controllers/moment.controller");
const {verifyLabelExists} = require("../middlewares/label.middleware");
const {verifyLogin , verifyPermission,} = require("../middlewares/auth.middleware");    // 验证登录

momentRouter.post("/", verifyLogin,createMoment);
//查看某个用户的所有动态
momentRouter.get('/',list);
momentRouter.get('/:momentId',detail);
//修改动态
momentRouter.patch('/:momentId',verifyLogin,verifyPermission,updateMoment);
//删除动态
momentRouter.delete('/:momentId',verifyLogin,verifyPermission,deleteMoment);
//给动态添加标签
momentRouter.post('/:momentId/label',verifyLogin,verifyPermission,verifyLabelExists,createLabel);
//获取动态配图
momentRouter.get('/images/:filename',getFileInfo);
module.exports = momentRouter;  // 导出路由